<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>绑定样式</title>

    <style>
        .basic{
            font-size: 20px;
            text-align: center;
            line-height: 50px;
            height: 50px;
        }
        .happy{
            background-color: hotpink;
            border: 10px solid deeppink;
        }

        .sad{
            background-color: skyblue;
            border: 10px solid deepskyblue;

        }
    </style>
</head>
<body>
  <div id="root">
           <div class="basic happy" :class="colorStyle" >

           </div>
  </div>


<script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.12/vue.js"></script>
<script>

    new Vue({
        el:'#root',
        data:{
            colorStyle: 'happy'

        }
    })


</script>
</body>
</html>